package com.gao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gao.mapper.UserMapper;
import com.gao.pojo.Class;
import com.gao.mapper.ClassMapper;
import com.gao.pojo.User;
import com.gao.service.ClassService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gao.vo.Class_users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author GaoHuoHuo
 * @since 2020-03-14
 */
@Service
public class ClassServiceImpl extends ServiceImpl<ClassMapper, Class> implements ClassService {
    @Autowired
    private ClassMapper ClassMapper;
    @Autowired
    private UserMapper UserMapper;
    @Override
    public List<Class_users> selClassList() {
        ArrayList<Class_users> classUserLise = new ArrayList<> ();
        List<Class> classList = ClassMapper.selectList ( null );
        for (Class aClass : classList) {
            Class_users classUsers = new Class_users ();
            classUsers.setCls ( aClass );
            User user = new User ();
            User setCid = user.setCid ( aClass.getId () );
            List<User> users = UserMapper.selectList ( new QueryWrapper<User> ( setCid ) );
            classUsers.setUsers ( users );
            classUserLise.add ( classUsers );
        }
        return classUserLise;
    }


}
